<?php
use yii\helpers\ArrayHelper;
use common\library\htmlHelper;

?>
<form class="layui-form" action="/works-class/edit">
    <div class="layui-form-item">
        <label class="layui-form-label">去向名称</label>
        <div class="layui-input-inline">
            <input type="text" name="class_name"
                   value="<?= ArrayHelper::getValue($info, 'class_name') ?>"
                   lay-verify="required" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">排序</label>
        <div class="layui-input-inline">
            <input type="text" name="sort" value="<?= ArrayHelper::getValue($info, 'sort') ?>"
                   class="layui-input"
                   placeholder="默认50，越大越靠前">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">是否显示</label>
        <div class="layui-input-block">
            <input type="radio" name="is_show" value="1"
                   title="显示" <?= htmlHelper::unsetOrEqual($info, 'is_show', 1, 'checked=""') ?>>
            <input type="radio" name="is_show" value="0"
                   title="隐藏" <?= htmlHelper::issetAndEqual($info, 'is_show', 0, 'checked=""') ?>>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <input type="hidden" name="<?= Yii::$app->request->csrfParam ?>"
                   value="<?= Yii::$app->request->csrfToken ?>">
            <input type="hidden" name="works_class_id"
                   value="<?= ArrayHelper::getValue($info, 'works_class_id') ?>">
            <button class="layui-btn" lay-submit lay-filter="submit-btn">保存</button>
        </div>
    </div>
</form>
<script>
    layui.use(['layer', 'form', 'upload', 'layedit'], function () {
        var layer = layui.layer,
            form = layui.form();
        form.on('submit(submit-btn)', function (data) {
            var loading = layer.load(0, {shade: <?=Yii::$app->params['layui_shade']?>, time: <?=Yii::$app->params['layui_time']?>});
            //增加编辑器内容
            $.post(data.form.action, data.field, function (rs) {
                layer.msg(rs.msg);
                if (rs.code === 0) {
                    setTimeout(function () {
                        window.location.href = rs.redirect;
                    }, <?=Yii::$app->params['layui_set_timeout']?>);
                }
                layer.close(loading);
            }, 'json');
            return false;
        });
    });
</script>